home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2001 / MacHack 2001.toast / pc / The Hacks / MacCleo / geoface / cardguess.c next >
Encoding:
C/C++ Source or Header  |  2001-06-23  |  3.8 KB  |  106 lines

  1. /*
  2.  *  cardguess.c
  3.  *  GLUTExamples
  4.  *
  5.  *  Created by ericslos on Fri Jun 22 2001.
  6.  *  Copyright (c) 2001 __CompanyName__. All rights reserved.
  7.  *
  8.  */
  9. #include <stdio.h>
  10.  
  11. int question( char* q )
  12. {
  13.     char a[16];
  14.  
  15.     printf( q );
  16.     fflush(stdout);
  17.     fgets(a, 16, stdin);
  18.     
  19.   //  printf("'%s'\n", a);
  20.     
  21.     return (strcmp(a,"y \n")==0);
  22. }
  23.  
  24. void card_guess()
  25. {
  26.     int    a;
  27.     int    isblack, isFirst, bit4, bit3, bit2, bit1;
  28.     
  29.     isblack = question( "are you concentrating?  " );
  30.     
  31.     isFirst = question( isblack ? "is your card black?  ": "is your card red?  ");
  32.     
  33.     if ( isblack )
  34.         bit4 = question(isFirst ? "is your card a CLUB? " : "is your card a SPADE?" );
  35.     else
  36.         bit4 = question(isFirst ? "is your card a DIAMOND? " : "is your card a HEART?" );
  37.  
  38.     
  39. /*    1 2 3 4 5 6 7 8 9  10 J Q K
  40.                  |
  41.            |            |
  42. */           
  43.    bit3 = question( bit4 ?  "is your card greater than a 6?" : "is your card less than 7?" );
  44.     if ( bit4 ) { // 7..K
  45.         bit2 = question( bit3 ?  "is your card greater than 9?" : "is your card less than 10?" );
  46.         if ( bit3 ) { // 10..K
  47.             bit1 = question( bit2 ? "is your card greater than a JACK?" : "is your card less than a QUEEN?" );
  48.             if ( bit2 ) { // Q..K
  49.                 question( bit1 ? "is your card a KING?" : "is your card a QUEEN?" );
  50.             } else { // 10..J
  51.                 question( bit1 ? "is your card a JACK?" : "is your card a 10?" );
  52.             }
  53.         } else { // 7..9
  54.             bit1 = question( bit2 ? "is your card greater than 8?" : "is your card a 9?" );
  55.             if ( bit2 )
  56.                 question( bit1 ? "is your card a 7?" : "is your card an 8?" );
  57.         }
  58.     } else { // A..6
  59.         bit2 = question( bit3 ?  "is your card greater than 3?" : "is your card less than 4?" );
  60.         if ( bit3 ) { // 4..6
  61.             bit1 = question( bit2 ? "is your card a 6?" : "is your card less than 6?" );
  62.             if ( !bit2 )
  63.                 question( bit1 ? "is your card a 5?" : "is your card an 4?" );
  64.         } else { // A..3
  65.             bit1 = question( bit2 ? "is your card greater than 2?" : "is your card less than a 3?" );
  66.             if (bit2)
  67.                 question( "is your card a 3?" );
  68.             else
  69.                 question( bit1 ? "is your card a 2?" : "is your card an ACE?" );
  70.         }
  71.     }
  72.     
  73.  
  74. }
  75.  
  76. void embarrass_kiki()
  77. {
  78.     question( "are you tired of card games?");
  79.     question( "do you want to play a different guessing game?");
  80.     question( "do you want Cleo to guess things about you?");
  81.     question( "are you a girl?");
  82.     question( "are you taller than 5 feet?");
  83.     question( "are you shorter than 6 feet?");
  84.     question( "are you just about 5 foot 4 ?");
  85.     question( "so you're shorter than your mom?");
  86.     question( "that's pretty short, huh?");
  87.     question( "do you have a teddy bear?");
  88.     question( "do you like boys?");
  89.     question( "do you know a boy named casey?");
  90.     question( "do you want me to change the subject?");
  91.  //   question( "is he cute?");
  92.     question( "did you ever go to Canada?");
  93.     question( "did the border guard ask you if you had something to declare?");
  94.     question( "did you declare 'I love your money?'");
  95.     question( "did you you were getting a computer this week?");
  96.     question( "did you ask your mom if this was true?");
  97.     question( "did she say no?");
  98.     question( "did you believe her?");
  99.     question( "has she ever misled you before?");
  100.     question( "were you silly to believe her this time?");
  101.     question( "are you starting to think that your mother set you up?");
  102.     question( "would you like to get your computer tonight?");
  103.     question( "can you guess what's in the box next to Eric?");
  104.     question( "can you please stop leaving your computer lying around?");
  105.     question( "is this hack over?");
  106. }